<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/WorkspaceTemplate.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="top">
        
    </ui:define>

    <ui:define name="left">
    </ui:define>

    <ui:define name="right">
       
    </ui:define>

    <ui:define name="content">
        <h:form prependId="false">
            <p:messages id="msgs" showDetail="true"/>
            <p:dataTable var="role" value="#{userRoleManagerBean.allRoles}" id="viewRoles">
                <f:facet name="header">
                    View all security roles
                </f:facet>

                <p:column headerText="Role Name" 
                          filterBy="#{role.roleName}">
                    <h:outputText value="#{role.roleName}"/>
                </p:column>

                <p:column headerText="Department" 
                          filterBy="#{role.department}">
                    <h:outputText value="#{role.department}"/>
                </p:column>

                <p:column headerText="Access Rights" >
                    <p:commandButton id="view#{role.id}" update="viewMulti msgs" value="View" action="#{userRoleManagerBean.selectRole(role.id)}" 
                                     oncomplete="dlg1.show()"  />
                </p:column>
            </p:dataTable>
            <p:dialog id="viewRightsDlg" widgetVar="dlg1" 
                      header="Access Rights for #{userRoleManagerBean.selectedRole.roleName}" 
                      width="700" height="400" hideEffect="clip" showEffect="clip">
                <p:panel>
                    <p:dataTable id="viewMulti" var="ar" value="#{userRoleManagerBean.selectedRole.accessRights}" 
                                 style="width: 100%"
                                 paginator="true" rows="5"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15"
                                 widgetVar="vrs">
                        <f:facet name="header">
                            <p:outputPanel>
                                <h:outputText value="Search all fields:" />
                                <h:inputText id="globalFilter" onkeyup="vrs.filter()" />
                            </p:outputPanel>
                        </f:facet>

                        <p:column headerText="Method Name" style="width: 25%"
                                  sortBy="#{ar.methodName}"
                                  filterBy="#{ar.methodName}">
                            <h:outputText value="#{ar.methodName}"/>
                        </p:column>
                        <p:column headerText="Method Path" style="width: 50%"
                                  sortBy="#{ar.methodPath}"
                                  filterBy="#{ar.methodPath}">
                            <h:outputText value="#{ar.methodPath}"/>
                        </p:column>
                        <p:column headerText="Method Category" style="width: 25%"
                                  sortBy="#{ar.methodCategory}"
                                  filterBy="#{ar.methodCategory}">
                            <h:outputText value="#{ar.methodCategory}"/>
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </p:dialog>
            <p:ajaxStatus>
                <f:facet name="start">
                    <h:graphicImage value="./../images/ajaxloading.gif"/>
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value=""/>
                </f:facet>
            </p:ajaxStatus>
        </h:form>
    </ui:define>

    <ui:define name="bottom">
       
    </ui:define>

</ui:composition>
